using System.Text.Json;

namespace rpc_service.config;

public class LoadConfig
{
    private static string _jsonPath;
    private static Config _config;

    public LoadConfig(string jsonPath)
    {
        _jsonPath = jsonPath;
    }

    public static Config Load()
    {
        if (_config != null)
        {
            return _config;
        }
        
        string jsonString = File.ReadAllText(_jsonPath);
        return JsonSerializer.Deserialize<Config>(jsonString)!;
    }
}